﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.fountain {
    import flash.events.*;
    import net.wooga.pets.loading.vos.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.fountain.*;
    import net.wooga.pets.models.world.*;

    public class InitTreeCommand extends Command {

		[Inject]
        public var event:InfoEvent;
		[Inject]
        public var tree:TreeModel;
		[Inject]
        public var user:UserModel;
		[Inject]
        public var world:WorldModel;

        override public function execute():void{
            var _local4:Object;
            if (this.event.info){
                _local4 = this.event.info;
                this.tree.id = _local4.id;
                this.tree.symbol = _local4.symbol;
                this.tree.readyAt = _local4.ready_at;
                this.tree.readyIn = _local4.ready_in;
            };
            var _local1:Boolean = ((!(this.user.isVisitFriendsMode())) && (this.world.hasAreaType(GameConstants.TYPE_FOUNTAIN)));
            var _local2 = (this.user.visitingFriendID == GameConstants.KARLA_FACEBOOK_ID);
            var _local3:Boolean = ((this.user.isVisitFriendsMode()) && (((this.tree.readyAt) || (_local2))));
            if (((_local1) || (_local3))){
                this.loadSymbol();
            } else {
                dispatch(new Event(EventConstants.HIDE_TREE));
            };
        }
        private function loadSymbol():void{
            var _local1:RequestEvent = new RequestEvent(EventConstants.SEND_REQUEST, this.onResult);
            _local1.addAssetRequest(ProtocolConstants.LOAD_SYMBOL, this.tree.symbol);
            dispatch(_local1);
        }
        private function onResult(_arg1:ResultVO):void{
            dispatch(new InfoEvent(EventConstants.SET_TREE_SYMBOL, this.tree.symbol));
            dispatch(new Event(EventConstants.SHOW_TREE));
            this.tree.startTimer();
        }

    }
}//package net.wooga.pets.controllers.fountain 
